/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    can.h
  * @brief   This file contains all the function prototypes for
  *          the can.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CAN_H__
#define __CAN_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern CAN_HandleTypeDef hcan1;

/* USER CODE BEGIN Private defines */
/***********************帧结构***********************/
/**
 * 模块间通讯是用标准帧
 * 11位中 5位用于拨码调节 3位用于模块类型分别 3位留着备用
 * ***   ***      *****
 * 备用   模块类型  模块id
 *
 * 模块类型 ：0为主站 1为AI 2为DI 3为DO
 */

#define DO_FUNC (3<<5)

#pragma pack(1)
typedef struct{
	uint16_t stdId; // 标准帧 11位 0-7FF
	uint32_t extId; // 扩展帧 29位 0-1FFFFFFF
	uint8_t buff[8]; // 数据
	uint8_t len; // 发送长度
}CAN_Msg_Def;
#pragma pack()
/* USER CODE END Private defines */

void MX_CAN1_Init(void);

/* USER CODE BEGIN Prototypes */
void My_CAN_Init(void);
void CAN_TX_ExtId_Msg(CAN_Msg_Def message);
void CAN_TX_StdId_Msg(CAN_Msg_Def message);
/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __CAN_H__ */

